package com.chensheng.dao;

import com.chensheng.model.ProductCategory;
import com.chensheng.model.ProductInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author:ChenSheng
 * @Description:
 * @Date: Created in 上午 8:09 2018/5/14 0014
 */
@Mapper
public interface ProductCategoryDAO {

    @Select({"select * from product_category"})
    List<ProductCategory> findAll();

    @Select({"select * from product_category limit #{start},#{offset}"})
    List<ProductCategory> findAllByPage(@Param("start") Integer start, @Param("offset") Integer offset);


    @Select({"select * from product_category where category_id=#{categoryId}"})
    ProductCategory findOne(@Param("categoryId") Integer categoryId);

    List<ProductCategory> selectByTypeList(@Param("typeIdList") List<Integer> typeIdList);

    @Select({"select count(category_id) from product_category"})
    Integer count();

    @Insert({"insert into product_category (category_name,category_type,create_time,update_time) " +
            "values(#{categoryName}, #{categoryType}, #{createTime}, #{updateTime})"})
    void insertOne(ProductCategory productCategory);

    @Update({"update product_category set category_name=#{categoryName},update_time=#{updateTime} where category_id=#{categoryId}"})
    void updateOne(ProductCategory productCategory);
}
